package com.common.security.factory.impl;

import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.common.factory.AbstractOauth2AuthenticationFactoryStrategyWrapper;
import com.common.security.authentication.Oauth2BusinessPasswordModeAuthentication;
import com.common.security.pojo.Oauth2BusinessPasswordMode;
import com.common.security.startegy.impl.BusinessPasswordAccountTypeStrategy;
import org.springframework.stereotype.Component;

@Component
public class Oauth2AuthenticationBusinessPasswordFactory extends AbstractOauth2AuthenticationFactoryStrategyWrapper<Oauth2BusinessPasswordMode, Oauth2BusinessPasswordModeAuthentication, BusinessPasswordAccountTypeStrategy> {
    public Oauth2AuthenticationBusinessPasswordFactory() {
    }

    public boolean support(String grantType) {
        return "businessPassword".equals(grantType);
    }

    protected Oauth2BusinessPasswordMode createMode(JSONObject bodyJsonObject) {
        return JSONUtil.toBean(bodyJsonObject, Oauth2BusinessPasswordMode.class);
    }
}
